<div class="title">
  <h1>Angriff auf <%=h @attack.position1 %>:<%=h @attack.position2 %>:<%=h @attack.position3 %></h1>
</div>

<div class="content">
  <table>
    <tr>
      <td class="description">Zeitpunkt:</td>
      <td class="def"><%=h @attack.zeitpunkt %></td>
    </tr>
    <tr>
      <td class="description">Ergebnis:</td>
      <td class="def">
        <%  if @attack.result %>
          gewonnen
        <% else %>
          verloren
        <% end %>
      </td>
    </tr>
  </table>
  <% if @attack.armies.count > 0 %>
    <div>
      <% @attack.armies.each do |army| %>
        <table>
          <tr>
            <th></th>
            <th class="heading">Angriff</th>
            <th class="heading">Verteidigung</th>
            <th class="heading">Leben</th>
            <th class="heading">Essenzen</th>
            <th class="heading">Kristalle</th>
            <th class="heading">Kraftsteine</th>
            <th class="heading">Goldharz</th>
          </tr>
          <tr>
            <td class="description"><%= link_to army.hero.name, attack_army_path(@attack, army) %></td>
            <td class="def" id="right"><%= n army.sum_angriff %></td>
            <td class="def" id="right"><%= n army.sum_verteidigung %></td>
            <td class="def" id="right"><%= n army.sum_leben %></td>
            <td class="def" id="right"><%= n army.essenzen %></td>
            <td class="def" id="right"><%= n army.kristalle %></td>
            <td class="def" id="right"><%= n army.kraftsteine %></td>
            <td class="def" id="right"><%= n army.goldharz %></td>
          </tr>
        </table>
      <% end %>
    </div>
    <div>
      <table>
        <tr>
          <th></th>
          <th class="heading">Essenzen</th>
          <th class="heading">Kristalle</th>
          <th class="heading">Kraftsteine</th>
          <th class="heading">Goldharz</th>
        </tr>
        <tr>
          <td class="description">Beute</td>
          <td class="def" id="right"><%= n @attack.beute_essenzen %></td>
          <td class="def" id="right"><%= n @attack.beute_kristalle %></td>
          <td class="def" id="right"><%= n @attack.beute_kraftsteine %></td>
          <td class="def" id="right"><%= n @attack.beute_goldharz %></td>
        </tr>
        <tr>
          <td class="description">Verluste</td>
          <td class="def" id="right"><%= n @attack.verluste_essenzen %></td>
          <td class="def" id="right"><%= n @attack.verluste_kristalle %></td>
          <td class="def" id="right"><%= n @attack.verluste_kraftsteine %></td>
          <td class="def" id="right"><%= n @attack.verluste_goldharz %></td>
        </tr>
        <tr>
          <td class="description">Gewinn</td>
          <td class="def" id="right"><%= n @attack.gewinn_essenzen %></td>
          <td class="def" id="right"><%= n @attack.gewinn_kristalle %></td>
          <td class="def" id="right"><%= n @attack.gewinn_kraftsteine %></td>
          <td class="def" id="right"><%= n @attack.gewinn_goldharz %></td>
        </tr>
      </table>
    </div>
  <% end %>
  <% if @attack.armies.count > 1 %>
    <div>
      <h2>Verteilung</h2>
      <table>
        <tr>
          <th></th>
          <th class="heading">Essenzen</th>
          <th class="heading">Kristalle</th>
          <th class="heading">Kraftsteine</th>
          <th class="heading">Goldharz</th>
        </tr>
        <% @attack.armies.each do |army| %>
          <tr>
            <td class="description"><%=h army.hero.name %></td>
            <td class="def" id="right"><%= n @attack.verteilung_essenzen(army) %></td>
            <td class="def" id="right"><%= n @attack.verteilung_kristalle(army) %></td>
            <td class="def" id="right"><%= n @attack.verteilung_kraftsteine(army) %></td>
            <td class="def" id="right"><%= n @attack.verteilung_goldharz(army) %></td>
          </tr>
        <% end %>
      </table>
    </div>
  <% end %>
  <% if @attack.defenders.count > 0 %>
    <div>
      <h2>Verteidiger</h2>
      <table>
        <tr>
          <th></th>
          <th class="heading">Angriff</th>
          <th class="heading">Verteidigung</th>
          <th class="heading">Leben</th>
        </tr>
        <% @attack.defenders.each do |defender| %>
          <tr>
            <td class="description"><%= link_to defender.name, attack_defender_path(@attack, defender) %></td>
            <td class="def" id="right"><%= n defender.sum_angriff %></td>
            <td class="def" id="right"><%= n defender.sum_verteidigung %></td>
            <td class="def" id="right"><%= n defender.sum_leben %></td>
          </tr>
        <% end %>
      </table>
    </div>
    <div>
      <h2>Verhältnis Angreifer/Verteidiger</h2>
      <table>
        <tr>
          <th></th>
          <th class="heading">Angriff</th>
          <th class="heading">Leben</th>
          <th class="heading">Punkte</th>
        </tr>
        <tr>
          <td class="description">Angreifer</td>
          <td class="def" id="right"><%= @attack.verhaeltnis_angriff %>
          <td class="def" id="right"><%= @attack.verhaeltnis_leben %>
          <td class="def" id="right"><%= @attack.verhaeltnis_punkte %>
        </tr>
      </table>
    </div>
  <% end %>
</div>

<% content_for :navigation do %>
  <li>
    <%= link_to 'Bearbeiten', edit_attack_path(@attack) %>
  </li>
  <li>
    <%= link_to 'Armeen', attack_armies_path(@attack) %>
    <ul>
      <% @attack.armies.each do |army| %>
        <li>
          <%= link_to army, attack_army_path(@attack, army) %>
        </li>
      <% end %>
    </ul>
  </li>
  <li>
    <%= link_to 'Verteidiger', attack_defenders_path(@attack) %>
    <ul>
      <% @attack.defenders.each do |defender| %>
        <li>
          <%= link_to defender, attack_defender_path(@attack, defender) %>
        </li>
      <% end %>
    </ul>
  </li>
<% end %>